package com.yuji.aacar.core.mvvm.appbase;


import android.support.multidex.MultiDexApplication;

/**
 * <li>Package:com.ttp.core.mvvm.appbase</li>
 * <li>Author: lining</li>
 * <li>Date: 2017/3/17</li>
 * <li>Description:Application基类</li>
 */

public abstract class CoreBaseApplication extends MultiDexApplication {

    @Override
    public void onCreate() {
        super.onCreate();
        initMVVM();
        initGlobleEnvConfig();
        initHttp();
        initFresco();
        initLogUtil();
        initHttpApis();
        initAppServicesMediators();
        initToast();
        initDB();
//        initAppServicesParameters();
    }

    private void initToast() {
    }

    /*** 初始化所有的APi 获取api所有的方法,可以多次初始化添加不同的API
     CoreServiceMediator.initAppAPIs(AHttpApi.class);
     CoreServiceMediator.initAppAPIs(BHttpApi.class);
     */
    public abstract void initHttpApis();

    /*** 初始化框架
     ViewModelManager.getInstance().addViewModelPlist(ViewModelPlist.hashMap);
     ViewModelManager.getInstance().setController(ExceptionManager.getInstance());
     */
    public abstract void initMVVM();

    /*** 初始化全局环境变量
     ViewModelManager.getInstance().addViewModelPlist(ViewModelPlist.hashMap);
     ViewModelManager.getInstance().setController(ExceptionManager.getInstance());
     */
    public abstract void initGlobleEnvConfig();

    /*** 初始化全局请求API
     HttpConfig.Builder builder=new HttpConfig.Builder();
     builder
     //.setHost("dealer.app.ttpai.cn")
     //.setAppUrl("https://api.ttpai.cn/ttpBidHallController/")
     .setHost("customer.app.ttpai.cn")
     .setAppUrl("https://api.ttpai.cn/app/")
     .setUuUserId(Tools.getuuUserId(this))
     .setVersion(Tools.getAppVersionName(this))
     .setToken("")
     .build();
     */
    public abstract void initHttp();

    /*** 初始化图片
     CoreFresco.init(this);
     */
    public abstract void initFresco();

    /*** 初始化log
     *
     LogUtil.Builder builder = new LogUtil.Builder();
     builder.allSwitch(true)
     .errorSwitch(false)
     .writerSwitch(false)
     .logType('e')
     .pathDir("/sdcard/")
     .logFileSaveDays(0)
     .logFileName("Log.txt")
     .myLogSdf(new SimpleDateFormat(
     "yyyy-MM-dd HH:mm:ss"))
     .logfile(new SimpleDateFormat("yyyy-MM-dd")).build();
     */
    public abstract void initLogUtil();

    /*** 初始化全局请求API
     CoreServiceMediator.initAppServicesMediators(new AServiceMediator());
     */
    public abstract void initAppServicesMediators();

    /*** 初始化全局请求参数API
     CoreServiceMediator.initAppServicesMediators(new AServiceMediator());
     */
//    public abstract void initAppServicesParameters();

    /*** 初始化GreenDao数据库

     */
    protected abstract void initDB();

    @Override
    public void onTerminate() {
        super.onTerminate();
    }
}
